//
//  WelcomeViewController.swift
//  WeiBo
//
//  Created by wukeng on 16/8/29.
//  Copyright © 2016年 wukeng. All rights reserved.
//

import UIKit
import SDWebImage

class WelcomeViewController: UIViewController {

    @IBOutlet weak var iconImage: UIImageView!
    @IBOutlet weak var iconViewBottomCon: NSLayoutConstraint!
    override func viewDidLoad() {
        super.viewDidLoad()
        let profileURLString = UserAccountViewModel.single.account?.avatar_large
        //??:1.如果前面的可选类型有值，那么将前面的可选类型进行解包并且合并
        //2.如果前面的可选类型为nil，那么直接使用后面的值
        let url = NSURL(string: profileURLString ?? "")
        
        iconImage.sd_setImageWithURL(url, placeholderImage: UIImage(named: "avatar_default_big"))
        
        iconViewBottomCon.constant = UIHeight - 150
        //执行动画
        //Damping : 阻力系数，阻力系数越大，弹动效果越不明显  0-1
        //initialSpringVelocity  初始速度
        UIView.animateWithDuration(1, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 1, options: .CurveEaseInOut, animations: {
                self.view.layoutIfNeeded()
            }) { (_) in
                UIApplication.sharedApplication().keyWindow?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
        }
    }

}
